package parkManage;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

public class ParkTest {

	// 车
	static ArrayList<CarModel> cars = new ArrayList<CarModel>();
	// 停车场:收费记录
	static ArrayList<ParkModel> parks = new ArrayList<ParkModel>();
	// 车位
	static ArrayList<PositionModel> positions = new ArrayList<PositionModel>();
	// 空闲车位号
	static TreeSet<Integer> frees = new TreeSet<Integer>();
	// 已用车位号
	static TreeSet<Integer> occupy = new TreeSet<Integer>();

	static int moeny;

	static Scanner scanner = new Scanner(System.in);

	/**
	 * 空闲车位:1-50
	 */
	public void freePosition() {
		for (int i = 1; i <= 50; i++) {
			frees.add(i);
		}
	}

	public void viewFree() {
		System.out.println("空闲车位：");
//		for (int i = 0; i < frees.size(); i++) {
//			if (i % 5 == 0)
//				System.out.println();
//			System.out.print(frees.) + "\t");
//		}
		int num = 0;
		for (int i : frees) {
			if (num % 5 == 0)
				System.out.println();
			System.out.print(i + "\t");
			num++;
		}
		System.out.println();
	}

	public void home() {
		CarModel carModel = new CarModel();
		PositionModel po = new PositionModel();
		ParkModel parkModel = new ParkModel();
		while (true) {
			System.out.println("========请选择===========");
			System.out.println("========1-停车===========");
			System.out.println("========2-取车===========");
			System.out.println("========3-查看空闲车位====");
			System.out.println("========4-查询车辆信息====");
			System.out.println("========5-查询车位信息====");
			System.out.println("========6-查询总费用======");
			System.out.println("========7-查询详细费用=====");
			System.out.println("========8-退出============");

			int key = Integer.parseInt(scanner.nextLine());

			if (key == 8)
				break;

			switch (key) {
			case 1:
				carModel.addCar();
				break;
			case 2:
				carModel.leaveCar();
				break;
			case 4:
				
				carModel.carDetails();
				break;
			case 3:
				viewFree();
				break;
			case 5:
				po.parkLot();
				break;
			case 6:
				parkModel.totalCost();
				if (parks.size() != 0)
					System.out.println("总费用：" + parks.get(parks.size() - 1).getCharge() + "元");
				break;
			case 7:
				parkModel.selectAll();
				break;
			default:
				break;
			}
			System.out.println("====点击回车继续...====");
			scanner.nextLine();
		}
	}

	public static void main(String[] args) {
		ParkTest park = new ParkTest();
		park.freePosition();

		park.home();
	}

}
